<template>
  <div id="app">
        <transition :name="transitionName">
            <keep-alive exclude="author,follow">
                <router-view/>
            </keep-alive>
        </transition>
  </div>
</template>

<script>
export default {
  name: 'app',
  data(){
        return {
            transitionName:""
        }
    },
    watch: {//使用watch 监听$router的变化
        $route(to, from) {
            //如果to的索引值为0，不添加任何动画；如果to索引大于from索引,判断为前进状态,反之则为后退状态
            if(to.meta.index > 0){
                if( to.meta.index < from.meta.index){
                    this.transitionName = 'slide-right';
                }else{
                    this.transitionName = 'slide-left';
                }
            }else if(to.meta.index == 0 && from.meta.index > 0){
                this.transitionName = 'slide-right';
            }

            //当然，如果你没有需要设置索引值为0的页面可以直接用着一段
            /*if( to.meta.index < from.meta.index){
                  this.transitionName = 'slide-right';
            }else{
                  this.transitionName = 'slide-left';
            }*/
        }
    }
}
</script>

<style>
html {
	    font-size: 50px
	}

	body {
	    font-size: 24px
	}

	@media screen and (min-width:320px) {
	    html {
	        font-size: 21.33px
	    }
	    body {
	        font-size: 12px
	    }
	}

	@media screen and (min-width:360px) {
	    html {
	        font-size: 24px
	    }
	    body {
	        font-size: 12px
	    }
	}

	@media screen and (min-width:375px) {
	    html {
	        font-size: 25px
	    }
	    body {
	        font-size: 12px
	    }
	}

	@media screen and (min-width:384px) {
	    html {
	        font-size: 25.6px
	    }
	    body {
	        font-size: 14px
	    }
	}

	@media screen and (min-width:400px) {
	    html {
	        font-size: 26.67px
	    }
	    body {
	        font-size: 14px
	    }
	}

	@media screen and (min-width:414px) {
	    html {
	        font-size: 27.6px
	    }
	    body {
	        font-size: 14px
	    }
	}

	@media screen and (min-width:424px) {
	    html {
	        font-size: 28.27px
	    }
	    body {
	        font-size: 14px
	    }
	}

	@media screen and (min-width:480px) {
	    html {
	        font-size: 32px
	    }
	    body {
	        font-size: 15.36px
	    }
	}

	@media screen and (min-width:540px) {
	    html {
	        font-size: 36px
	    }
	    body {
	        font-size: 17.28px
	    }
	}

	@media screen and (min-width:720px) {
	    html {
	        font-size: 48px
	    }
	    body {
	        font-size: 23.04px
	    }
	}

	@media screen and (min-width:750px) {
	    html {
	        font-size: 50px
	    }
	    body {
	        font-size: 24px
	    }
	}
	body {
	    min-width: 320px;
	    font-family: Arial,Helvetica,STHeiTi,sans-serif;
	    background: #ffffff;
	}
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
  width: 15rem;
  margin: 0 auto;
  line-height:1.1;
}
/* 页面跳转动画 */
.slide-right-enter-active,
  .slide-right-leave-active,
  .slide-left-enter-active,
  .slide-left-leave-active {
      will-change: transform;
      transition: all .3s;
      position: absolute;
      width:100%;
      left:0;
  }
  .slide-right-enter {
      transform: translateX(-100%);
  }
  .slide-right-leave-active {
      transform: translateX(100%);
  }
  .slide-left-enter {
      transform: translateX(100%);
  }
  .slide-left-leave-active {
      transform: translateX(-100%);
  }
/* 页面跳转动画 */
/* 切换页面的背景 */
.index_active_bg{
    padding-bottom: 1.96rem;
    background: #FFFFFF;
}
.shop_details_active{
    background: #F8F8F8;
}
.address_active_bg{
    background:#F5F5F5;
}
.business_active_bg{
    background:#ededed;
}
.coupon_active_bg{
    background:linear-gradient(270deg,rgba(26,185,163,1) 0%,rgba(31,223,160,1) 100%);
}
</style>
